package com.example.administrator.zkdemo.db.orm.manager;

/**
 * Created with Android Studio.
 * 描述: ${DESCRIPTION}
 * Date: 2018/11/22
 * Time: 14:22
 *
 * @author 晏琦云
 * @version ${VERSION}
 */

import android.database.Cursor;

import com.example.administrator.zkdemo.core.interfaces.DatabaseInterface;

import java.util.List;

public class DatabaseProvider extends AbstractProvider
        implements DatabaseInterface {
    public DatabaseProvider(Provider paramProvider) {
        super(paramProvider);
    }

    public static DatabaseInterface getInstance(Provider paramProvider) {
        return new DatabaseProvider(paramProvider);
    }

    public Number executeInsert(String paramString, DatabaseInterface.SQLCommand paramSQLCommand) {
        return (Number) getProvider().invoke("db-insert", new Object[]{paramString, paramSQLCommand});
    }

    public Cursor executeQuery(String paramString, DatabaseInterface.SQLCommand paramSQLCommand) {
        return (Cursor) getProvider().invoke("db-query", new Object[]{paramString, paramSQLCommand});
    }

    public void executeSql(String paramString1, String paramString2, Object[] paramArrayOfObject) {
        getProvider().invoke("db-execsql", new Object[]{paramString1, paramString2, paramArrayOfObject});
    }

    public boolean executeTransaction(String paramString, List<DatabaseInterface.SQLCommand> paramList) {
        return ((Boolean) getProvider().invoke("db-transaction", new Object[]{paramString, paramList})).booleanValue();
    }

    public void executeUpdate(String paramString, DatabaseInterface.SQLCommand paramSQLCommand) {
        getProvider().invoke("db-update", new Object[]{paramString, paramSQLCommand});
    }

    public int getIntOption(String paramString, int paramInt) {
        return ((Integer) getProvider().invoke("system-getint", new Object[]{paramString, Integer.valueOf(paramInt)})).intValue();
    }

    public String getStrOption(String paramString1, String paramString2) {
        return (String) getProvider().invoke("system-getstr", new Object[]{paramString1, paramString2});
    }

    public void open(String paramString, Integer paramInteger) {
        getProvider().invoke("db-open", new Object[]{paramString, paramInteger});
    }

    public int setIntOption(String paramString, int paramInt) {
        return ((Integer) getProvider().invoke("system-setint", new Object[]{paramString, Integer.valueOf(paramInt)})).intValue();
    }

    public int setStrOption(String paramString1, String paramString2) {
        return ((Integer) getProvider().invoke("system-setstr", new Object[]{paramString1, paramString2})).intValue();
    }

    public int systemFree() {
        return ((Integer) getProvider().invoke("system-free", new Object[0])).intValue();
    }

    public void systemInit() {
        getProvider().invoke("system-init", new Object[0]);
    }

    public void systemInitOptionTable() {
        getProvider().invoke("system-init-optiontable", new Object[0]);
    }
}
